package com.example.demo.common;

import lombok.Data;

/**
 * @ClassName: DataResult
 * TODO:写注释
 * @Author: zjf
 * @CreateDate: 2020-11-03 16:27
 * @Version: 0.0.1
 */
@Data
public class DataResult<T> {
    private Integer code;
    private String msg;
    private T data;


    public DataResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public DataResult(String msg, T data) {
        this.msg = msg;
        this.data = data;
    }

    public DataResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public DataResult(String msg) {
        this.msg = msg;
    }

    public static <T> DataResult  success(){
        return new DataResult<T>(200,"Success");
    }

    public static <T> DataResult  failure(String msg){
        return new DataResult<>(404,msg,null);
    }
}
